package com.example.prison.mapper;

import com.example.prison.entity.PushManagement;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
* @author jiang
* @description 针对表【push_management】的数据库操作Mapper
* @createDate 2023-05-29 16:43:34
* @Entity com.example.prison.entity.PushManagement
*/
@Mapper
public interface PushManagementMapper extends BaseMapper<PushManagement> {

    @Select("<script>select * from push_management " +
            " <where> " +
            " <if test=\"alarmLevel != null and alarmLevel != ''\">and alarm_level like concat('%',#{alarmLevel},'%') </if> " +
            " </where> " +
            "order by id desc</script>")
    List<PushManagement> get(@Param("alarmLevel") String alarmLevel);

    @Insert("insert into push_management(alarm_level, push_personnel, note, push_frequency) " +
            "values (#{alarmLevel}, #{pushPersonnel}, #{note}, #{pushFrequency})")
    int add(PushManagement push);

    @Delete("<script>delete from push_management where id in <foreach collection=\"ids\" item=\"item\" open=\"(\" separator=\",\" close=\")\">#{item} </foreach> </script>")
    void deletePush(@Param("ids") Integer[] ids);

    @Update("update push_management set push_personnel=#{push.pushPersonnel},note=#{push.note},push_frequency=#{push.pushFrequency} where id = #{id}")
    int updatePush(PushManagement push,Integer id);

    @Update("update push_management set alarm_level=#{push.alarmLevel}, push_personnel=#{push.pushPersonnel}, note=#{push.note},push_frequency=#{push.pushFrequency} where id = #{id}")
    int updatePushFail(PushManagement push,Integer id);

    @Select("select * from push_management where id=#{id}")
    PushManagement getById(@Param("id") Integer id);

    @Select("select * from push_management where id=#{id}")
    List<PushManagement> getByAlarmId(@Param("id") Integer id);

    @Select("select * from push_management where alarm_level=#{alarmLevel}")
    List<PushManagement> getByAlarmLevel(@Param("alarmLevel") String alarmLevel);

    @Select("select * from push_management where alarm_level=#{alarmLevel}")
    PushManagement getOneByAlarmLevel(@Param("alarmLevel") String alarmLevel);
}




